<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use yii\bootstrap\Alert;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>

<div class="wrap">

    <?php
    if (!Yii::$app->user->isGuest):
        ?>

        <div class="leftMeun" id="leftMeun">
            <div id="logoDiv">
                <p id="logoP"><span>
                    <?= Yii::t('app', 'host_name'); ?>
                </span></p>
            </div>
            <div id="personInfor">
                <?php
                if (Yii::$app->user->isGuest):
                    ?>
                    <p>
                        <?= Html::a(Yii::t('app', 'login'), ['site/login']) ?>
                    </p>
                    <?php

                else:
                    ?>
                    <p id="userName">
                        <?php
                        echo Yii::$app->user->identity->username;
                        ?>
                    </p>
                    <p><span>
                    <?php
                    echo Yii::$app->user->identity->channels_name;
                    ?>
                </span></p>
                    <p>

                        <?= Html::a(Yii::t('app', 'logout'), ['site/logout']) ?>
                    </p>
                    <?php
                endif;
                ?>
            </div>
            <div class="meun-title">包管理</div>
            <!--        <div class="meun-item meun-item-active" href="#sour" aria-controls="sour" role="tab" data-toggle="tab"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>资源管理</div>-->
            <!--        <div class="meun-item" href="#char" aria-controls="char" role="tab" data-toggle="tab">权限管理</div>-->
            <?php
            echo Nav::widget([
                'options' => ['class' => 'meun'],
                'items' => [
                    ['label' => ' 渠道管理', 'url' => ['/user/index'], 'linkOptions' => ['class' => 'glyphicon glyphicon-road'], 'options' => ['class' => 'meun-item'], 'visible' => isset(Yii::$app->user->identity->is_admin) && Yii::$app->user->identity->is_admin == 1 ? 1 : 0],
                    ['label' => ' 产品管理', 'url' => ['/product/index'], 'linkOptions' => ['class' => 'glyphicon glyphicon-inbox'], 'options' => ['class' => 'meun-item']],
//                    ['label' => ' 激活列表', 'url' => ['/active/index'], 'linkOptions' => ['class' => 'glyphicon glyphicon-flag'], 'options' => ['class' => 'meun-item'], 'visible' => isset(Yii::$app->user->identity->is_admin) && Yii::$app->user->identity->is_admin == 1 ? 1 : 0],

//                Yii::$app->user->isGuest ? (
//                ['label' => 'Login', 'url' => ['/site/login']]
//                ) : (
//                    '<li>'
//                    . Html::beginForm(['/site/logout'], 'post', ['class' => 'navbar-form'])
//                    . Html::submitButton(
//                        'Logout (' . Yii::$app->user->identity->username . ')',
//                        ['class' => 'btn btn-link']
//                    )
//                    . Html::endForm()
//                    . '</li>'
//                )
                ],
            ]);
            ?>


        </div>
        <?php

    endif;
    ?>

    <!--    --><?php
    //    NavBar::begin([
    //        'brandLabel' => Yii::t('app', 'host_name'),
    //        'brandUrl' => Yii::$app->homeUrl,
    //        'options' => [
    //            'class' => 'navbar-inverse navbar-fixed-top',
    //        ],
    //    ]);
    //    echo Nav::widget([
    //        'options' => ['class' => 'navbar-nav navbar-right'],
    //        'items' => [
    ////            ['label' => 'Home', 'url' => ['/site/index']],
    ////            ['label' => 'About', 'url' => ['/site/about']],
    ////            ['label' => 'Contact', 'url' => ['/site/contact']],
    //            ['label' => '激活列表', 'url' => ['/active/index']],
    //            ['label' => '产品管理', 'url' => ['/product/index']],
    //            ['label' => '渠道管理', 'url' => ['/user/index'],'visible'=>isset(Yii::$app->user->identity->is_admin) && Yii::$app->user->identity->is_admin==1?1:0],
    //            Yii::$app->user->isGuest ? (
    //                ['label' => 'Login', 'url' => ['/site/login']]
    //            ) : (
    //                '<li>'
    //                . Html::beginForm(['/site/logout'], 'post', ['class' => 'navbar-form'])
    //                . Html::submitButton(
    //                    'Logout (' . Yii::$app->user->identity->username . ')',
    //                    ['class' => 'btn btn-link']
    //                )
    //                . Html::endForm()
    //                . '</li>'
    //            )
    //        ],
    //    ]);
    //    NavBar::end();
    //    ?>


    <div class="container">
        <?php

        if (Yii::$app->getSession()->hasFlash('success')) {
            echo Alert::widget([
                'options' => [
                    'class' => 'alert-success', //这里是提示框的class
                ],
                'body' => Yii::$app->getSession()->getFlash('success'), //消息体
            ]);
        }
        if (Yii::$app->getSession()->hasFlash('error')) {
            echo Alert::widget([
                'options' => [
                    'class' => 'alert-error',
                ],
                'body' => Yii::$app->getSession()->getFlash('error'),
            ]);
        }
        ?>
        <?php
        if (!Yii::$app->user->isGuest):
            $WmProductSearch = Yii::$app->request->get('WmProductSearch');
            $WmActiveSearch = Yii::$app->request->get('WmActiveSearch');
            if (isset($WmProductSearch['uid'])):
                $info = \app\models\WmUser::findOne($WmProductSearch['uid']);
                $this->params['breadcrumbs'][] = ['label' => $info['channels_name']];
            elseif(isset($WmActiveSearch['pid'])):
                $info = \app\models\WmProduct::findOne($WmActiveSearch['pid']);
                $this->params['breadcrumbs'][] = ['label' => $info['product_name'],'url'=>['product/index','WmProductSearch[uid]'=>3]];
            endif;


            ?>
        <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?>

            <?php

        endif;
        ?>
        <?= $content ?>


    </div>

</div>


<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
